package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 服务分类
 * </p>
 *
 * @author linan
 * @date 2023-06-28
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceCategoryAttributeEnum", description = "所属类型 #{WATER_POINT:水点;ELECTRIC_BOX:电箱;GAS_POINT:气点;LIFTING_POINT:吊点;NETWORK:网络-枚举")
public enum ServiceCategoryAttributeEnum implements BaseEnum {

    /**
     * WATER_POINT="水点"
     */
    WATER_POINT("水点"),
    /**
     * ELECTRIC_BOX="电箱"
     */
    ELECTRIC_BOX("电箱"),
    /**
     * GAS_POINT="气点"
     */
    GAS_POINT("气点"),
    /**
     * LIFTING_POINT="吊点"
     */
    LIFTING_POINT("吊点"),
    /**
     * NETWORK="网络"
     */
    NETWORK("网络"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceCategoryAttributeEnum match(String val, ServiceCategoryAttributeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceCategoryAttributeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceCategoryAttributeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "WATER_POINT,ELECTRIC_BOX,GAS_POINT,LIFTING_POINT,NETWORK", example = "WATER_POINT")
    public String getCode() {
        return this.name();
    }

}
